package com.woniuxy.service.impl;

import com.woniuxy.client.AliyunClient;
import com.woniuxy.config.AiServiceProperties;
import com.woniuxy.service.AiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * AI服务实现类
 * 实现AI相关的业务逻辑
 */
@Service
public class AiServiceImpl implements AiService {
    private final AliyunClient aliyunClient;
    private final AiServiceProperties properties;
    
    @Autowired
    public AiServiceImpl(AliyunClient aliyunClient, AiServiceProperties properties){
        this.aliyunClient = aliyunClient;
        this.properties =  properties;
    }
    
    /**
     * 获取AI响应
     * @param message 用户输入的消息
     * @return 返回AI的响应内容
     */
    @Override
    public String getAiResponse(String message) {
        String response = aliyunClient.sendMessage(message).block();
        if (response != null) {
            return response;
        } else {
            return "抱歉，AI助手当前无法响应，请稍后再试。";
        }
    }
}
